<script>
  var lengthOfLastWord = function(s) {
    const arr = s.split(' ');
    const wordArr = arr.filter(item => item !== '')
    return wordArr[wordArr.length - 1].length;
  };
</script>